package com.apexedu.eas.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.apexedu.eas.annotation.Query;
import com.apexedu.eas.entity.Gxxs0101;
import com.apexedu.eas.entity.TxsSscwxx;
import com.apexedu.eas.entity.TxsSsfjxx;

@Repository
public class TxsSsfjxxDao extends BasisDao<TxsSsfjxx, Long> {
	
	// 获取所有的宿舍社区
	@Query(value = "select distinct(sq.sqm) sqm,sq.id id from  @TxsSssq sq,@TxsSscwxx cw where sq.id=cw.sssq and cw.nj=? and cw.zzjg=? and cw.zy=? and cw.bj=? and cw.rzxb=? ", replace = true)
	public List<Map<String, String>> getSssq(Integer nj, Integer zzjg, Integer zy, Integer bj, Integer rzxb) {
		return null;
	}

	// 获取所有的宿舍楼名称
	@Query(value = "select distinct(ssl.sslmc) sslmc,ssl.id id from  @TxsSslxx ssl,@TxsSscwxx cw where ssl.id=cw.ssl and cw.nj=? and cw.zzjg=? and cw.zy=? and cw.bj=? and cw.rzxb=? ", replace = true)
	public List<Map<String, String>> getSslmc(Integer nj, Integer zzjg, Integer zy, Integer bj, Integer rzxb) {
		return null;
	}

	// 根据宿舍社区获取所有的宿舍楼名
	@Query(value = "select distinct(LC) from  @TxsSscwxx where nj=? and zzjg=? and zy=? and bj=? and rzxb=? order by LC", replace = true)
	public List<Map<String, String>> getSslc(Integer nj, Integer zzjg, Integer zy, Integer bj, Integer rzxb) {
		return null;
	}

	// 根据学号查询学生
	@Query(value = "select * from Gxxs0101 where xh = ?")
	public Gxxs0101 getGxxs0101ByXh(String userId) {
		return null;
	}

	// 根据id查询学生
	@Query(value = "select * from  Gxxs0101  where id = ?")
	public Gxxs0101 getGxxs0101ById(Long id) {
		return null;
	}

	// 根据 入住性别、年级、院系、专业、班级 、优先级 获取初始可选宿舍列表
	@Query(value = "select id,sssq,ssl,lc,ssfj,cwdm,cwmc,yfpyxj from  @TxsSscwxx  where gxxs0101 is null and syzt=2 and yfpzt=1 and rzxb=? and nj=? and zzjg=? and zy=? and bj=? and yfpyxj=? ", replace = true)
	public List<Map<String, String>> getRoomlist(Integer rzxb, Integer nj, Integer zzjg, Integer zy, Integer bj,
			Integer yfpyxj) {
		return null;
	}

	// 根据 社区号、楼号、楼层、入住性别、年级、院系、专业、班级 、优先级 获取可选宿舍列表
	@Query(value = "select room.id id,room.sssq sssq,sqm,room.ssl ssl,sslmc,room.lc lc,room.ssfj ssfj,fjmc,room.cwdm cwdm,room.cwmc cwmc,room.gxxs0101 gxxs0101 from txs_sssq ,txs_sslxx , txs_ssfjxx,( select cw.id id,cw.sssq sssq,cw.ssl ssl,cw.lc lc,cw.ssfj ssfj,cw.cwdm cwdm,cw.cwmc cwmc,case when cw.gxxs0101 is null then -1 else cw.gxxs0101 end gxxs0101 from ( select * from @TxsSscwxx where nj=? and zzjg=? and zy=? and bj=? and yfpyxj=? and yfpzt=1) cw where cw.sssq=? and cw.ssl=? and cw.lc=?  union select -1 id,cw.sssq sssq,cw.ssl ssl,cw.lc lc,cw.ssfj ssfj,cw.cwdm cwdm,cw.cwmc cwmc,-1 gxxs0101 from txs_sscwxx cw where cw.sssq=? and cw.ssl=? and cw.lc=?  and nvl(cw.bj,0）!=? ) room where room.sssq=txs_sssq.id and room.ssl=txs_sslxx.id and room.ssfj=txs_ssfjxx.id ", replace = true)
	public List<Map<String, String>> getFloorRoomlist(Integer nj, Integer zzjg, Integer zy, Integer bj, Integer yfpyxj,
			Long sssqid, Long sslid, Long lcid, Long sssq, Long ssl, Long lc, Integer bjid) {
		return null;
	}

	// 根据 社区号、楼号、楼层、入住性别、年级、院系、专业、班级 、优先级 获取可选宿舍列表
	@Query(value = "select id,sssq,ssl,lc,ssfj,cwdm,cwmc,yfpyxj from  @TxsSscwxx  where  rzxb=? and nj=? and zzjg=? and zy=? and bj=? and sssq=? and ssl=? and lc=? and yfpyxj<? and gxxs0101 is null and syzt=2 and yfpzt=1 ", replace = true)
	public List<Map<String, String>> getRoomlistByYxj(Integer rzxb, Integer nj, Integer zzjg, Integer zy, Integer bj,
			Long sssqid, Long sslid, Long lcid, Integer yfpyxj) {
		return null;
	}

	// 根据 社区号、楼号、楼层、房间号、床位号、入住性别、年级、院系、专业、班级 获取目标宿舍
	@Query(value = "select * from  @TxsSscwxx  where  rzxb=? and nj=? and zzjg=? and zy=? and bj=? and sssq=? and ssl=? and lc=? and ssfj=? and id=? and syzt=2 and yfpzt=1 ", replace = true)
	public TxsSscwxx getCw(Integer rzxb, Integer nj, Integer zzjg, Integer zy, Integer bj, Long sssqid, Long sslid,
			Long lcid, Long fjid, Long cwid) {
		return null;
	}

	// 保存获取宿舍的结果
	@Query(value = "update  @TxsSscwxx set syzt=1, gxxs0101=? where id=? and gxxs0101 is null and syzt=2 and yfpzt=1 ", replace = true, update = true)
	public Integer save(Long xsid, Long id) {
		return null;
	}

	// 记录当前学生选择宿舍的信息
	@Query(value = "insert into Txs_ssxqjl (id,gxxs0101,type,cw) values (usr_yx.fnextid('TXS_SSXQJL' ), ?, '选择', ?) ", update = true)
	public Integer saveChoose(Long xsid, Long cwid) {
		return null;
	}

	// 记录当前学生退选宿舍的信息
	@Query(value = "insert into Txs_ssxqjl (id,gxxs0101,type,cw) values (usr_yx.fnextid('TXS_SSXQJL' ), ?, '退选', ?) ", update = true)
	public Integer saveDelete(Long xsid, Long cwid) {
		return null;
	}

	// 获取当前学生修改宿舍的次数
	@Query(value = "select count(id) from Txs_ssxqjl  where  gxxs0101=? and type=? ", count = true)
	public Integer getTimes(Long xsid, String type) {
		return null;
	}

	// 获取当前学生是否已选宿舍
	@Query(value = "select count(id) from @TxsSscwxx where gxxs0101=? ", replace = true, count = true)
	public Integer getCount(Long xsid) {
		return null;
	}

	// 退选宿舍
	@Query(value = "UPDATE TXS_SSCWXX SET GXXS0101 = null, xh = null,GBT_XBDM = null,LXFS = null,GXJG0101_FDY = null,GXJG0101_BZR = null,SFSZ = null , YFPZT = 1, SYZT = 2,RZRQ =null where bj  = ? and GXXS0101 = ? and id = ?", replace = true, update = true)
	public Integer cancel(Integer bj, Long xsid, Long cwid) {
		return null;
	}

	// 获取当前学生修改宿舍的次数
	@Query(value = "select count(id) from Txs_ssxqjl  where  gxxs0101=? ", count = true)
	public Integer getXqcs(Long xsid) {
		return null;
	}

	// 根据考生号查询当前宿舍床位信息
	@Query(value = "select cw.id id,cw.cwmc cwmc,sq.sqm sqm,ssl.sslmc sslmc,fj.fjmc fjmc from Gxxs0101 g,txs_sssq sq,txs_sslxx ssl ,txs_ssfjxx fj,txs_sscwxx cw where cw.gxxs0101=g.id and cw.sssq=sq.id and cw.ssl=ssl.id and cw.ssfj=fj.id and g.ksdjh=?")
	public List<Map<String, String>> getCwByXh(String userid) {
		return null;
	}

}
